<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //属性的通用特征
    var people = {
      _name: undefined,
      sex: '男',
      get name() {
        console.log('获取name属性' + this._name);
        return this._name
      },
      set name(val) {
        console.log('为name属性进行赋值操作');
        this._name = val
      }
    }
    console.log(people.name);
    people.name = '小明'
    console.log(people.name);

  </script>
</body>

</html>